// pages/classFinished/classFinished.js
var klassModel = require('../../models/klass.js')
var gradeModel = require('../../models/grade.js')
var noticeModel = require('../../models/notice.js')
var getNoticeOperation = require('../../operation/getNoticesOperation.js')
let klass = null

Page({

  /**
   * 页面的初始数据
   */
  data: {
    grade: null,
    klass: null,
    password:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {    
    klass = getApp().globalData.param
    // 将口令存在剪切板中
    wx.setClipboardData({
      data: klass.password
    })
    
    this.setData({
      // grade: gradeModel.getGradeByEnrolDate(klass.enrolDate),
      klass: klass,      
      password: klass.password
    })

    wx.showShareMenu({
      withShareTicket: true
    })

    // 添加完班级后，更新用户数据
    getApp().updateUserInfo(null)

    // 获取系统默认生成的通知信息
    getNoticeOperation.getNotices('received')
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    klass = null
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  onShareAppMessage: function (options) {
    return noticeModel.shareInviteNotice(this,klass, options)
  },

  next:function() {
    wx.switchTab({
      url: '../noticeList/noticeList',
    })
  }
})